package cn.outsourcing.supermarket.converter;

import cn.outsourcing.supermarket.converter.transform.BooleanToIntegerTransform;
import cn.outsourcing.supermarket.po.HiolabsSpecification;
import cn.outsourcing.supermarket.vo.backstage.BackstageSpecificationVO;
import cn.outsourcing.supermarket.vo.hiolabs.HiolabsSpecificationVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 规格转换器
 *
 * @author gzkemays
 * @since 2021/10/22 15:31
 */
@Mapper(uses = {BooleanToIntegerTransform.class})
public interface HiolabsSpecificationConverter {
  HiolabsSpecificationConverter INSTANCE = Mappers.getMapper(HiolabsSpecificationConverter.class);

  /**
   * 转化为自身值对象
   *
   * @param specification 原 po 对象
   * @return 自身值对象
   */
  HiolabsSpecificationVO convertToVo(HiolabsSpecification specification);
  /**
   * 转化为自身值对象 list
   *
   * @param specification 原 po 对象
   * @return 自身值对象 list
   */
  List<HiolabsSpecificationVO> convertToVoList(List<HiolabsSpecification> specification);

  /**
   * 转化为后台缺省值对象
   *
   * @param specification 原 po 对象
   * @return 后台缺省值对象
   */
  @Mappings({
    @Mapping(source = "specification.name", target = "label"),
    @Mapping(source = "specification.sortOrder", target = "value")
  })
  BackstageSpecificationVO convertToBackstageVo(HiolabsSpecification specification);
  /**
   * 转化为后台缺省值对象列表
   *
   * @param specification 原 po 对象
   * @return 后台缺省值对象列表
   */
  List<BackstageSpecificationVO> convertToBackstageVoList(List<HiolabsSpecification> specification);
}
